package com.raccoon.ibatis.kjy;

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class SampleDB {

	private static SqlMapClient sqlMapper;

	static {
		try {
			Reader reader = Resources
					.getResourceAsReader("com/raccoon/ibatis/config/SqlMapConfig.xml");
			sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static Map selectMemberAll(HashMap map) throws SQLException {
		return sqlMapper.queryForMap("selectMember_dynamic_1", map, "");
	}

	public static List selectMemeberList(HashMap map) throws SQLException {
		return sqlMapper.queryForList("selectMember_dynamic_1", map);
	}

	public static void main(String[] args) {
		SampleDB db = new SampleDB();

		try {
			HashMap param = new HashMap();
			param.put("USRE_KEY", "0");
			Map map = db.selectMemberAll(param);
			
			System.out.println(map);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}